home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6220 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.iadfw.net!usenet
  2. From: alpet@airmail.net (Adam Peterson)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP: Illegal Pointer Arithmetic
  5. Date: Fri, 23 Feb 1996 04:15:56 GMT
  6. Organization: customer of Internet America
  7. Message-ID: <4gj85g$o0h@news-f.iadfw.net>
  8. References: <4gj0ug$730@news.one.net>
  9. NNTP-Posting-Host: dal24-12.ppp.iadfw.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Oren Levin <oren@one.net> wrote:
  13.  
  14. >I was wondering if someone could help me. I'm in the midst of learning
  15. >C/C++ and am trying to program the examples in Andrew Birnstock and John
  16. >Rex's book "Practical Algorithyms for Programers." I am using Symentec's
  17. >Think C++ (v 6 - Mac).
  18. >The following code is giving me a "illegal pointer arithmetic" error.
  19. >I'm trying to strip the carrage return off of a line of text read from a
  20. >file.
  21.  
  22. >TIA for the help.
  23. >Oren Levin
  24. >oren@one.net
  25.  
  26. >=== code snippet ===
  27. >        while (! feof (fin))
  28. >        {
  29. >            /* read a record */
  30. >            if (fgets (buffer, 127, fin) == NULL)
  31. >                break;
  32. >            
  33. >            /* get rid of the trailing carrage return */
  34. >            buffer [strlen (buffer) - 1] = "\0";
  35.  
  36. Try changing the "\0" to be '\0'.
  37.  
  38. Adam
  39.  
  40.  
  41.